package com.longteng.diamond.interceptor;

import com.longteng.diamond.filter.UrlFilter;
import com.longteng.diamond.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by Administrator
 * DATE : 2018/5/20
 * TIME : 16:28
 * PROJECT : java-lesson
 * PACKAGE : com.longteng.lesson
 *
 * @author <a href="mailto:taki@qq.com">Administrator</a>
 */
@Configuration
public class MyWebAppConfigurer extends WebMvcConfigurerAdapter {
    /**注入userService**/
    @Autowired
    private UserService userService;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        MyInterceptor myInterceptor=new MyInterceptor(userService);
        registry.addInterceptor(myInterceptor).addPathPatterns("/**").
                excludePathPatterns("/loginController/loginPage").excludePathPatterns("/loginController/loginSystem")
        .excludePathPatterns(UrlFilter.resolvePath);
        /**还要写两个：1.用户注册页面，2.注册请求**/
        super.addInterceptors(registry);
    }
}
